package org.mch.swingm.core;

import java.awt.Color;
import java.awt.Font;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import org.jdesktop.swingx.JXTextField;

/**
 * 描述：</BR>
 *
 * @author MCH；Date：2008-10-01
 *
 */
public class MTextField extends JXTextField implements FocusListener, MouseListener {
	private static final long serialVersionUID = -6719985114441139389L;

	public MTextField() {
		this(null);
	}

	public MTextField(String promptText) {
		this(promptText, null);
	}

	public MTextField(String promptText, Color promptForeground) {
		this(promptText, promptForeground, null);
	}

	public MTextField(String promptText, Color promptForeground, Color promptBackground) {
		super(promptText, promptForeground, promptBackground);
		initMCH();
	}

	protected void initMCH() {
		setFont(new Font("宋体", Font.PLAIN, 13));//
		addFocusListener(this);
	}

	@Override
	public void focusGained(FocusEvent e) {// 获得了焦点
		MTextField mtf = ((MTextField) e.getSource());
		mtf.selectAll();
	}

	@Override
	public void focusLost(FocusEvent e) {
		MTextField mtf = ((MTextField) e.getSource());
		mtf.select(0, 0);
	}

	@Override
	public void mouseClicked(MouseEvent e) {
	}

	@Override
	public void mousePressed(MouseEvent e) {
	}

	@Override
	public void mouseReleased(MouseEvent e) {
	}

	@Override
	public void mouseEntered(MouseEvent e) {
	}

	@Override
	public void mouseExited(MouseEvent e) {
	}

}
